import { Inject } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { AutomationTaskEntity } from '../../entity/task'; 
import { AutomationTaskService } from '../../service/app/task';

/**
 * 执行任务
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: AutomationTaskEntity,
  service: AutomationTaskService,
  pageQueryOp: {
    keyWordLikeFields: [],
    fieldEq: [],
    fieldLike: [],
    where: async (ctx) => {
      const { pipelineId } = ctx.request.body;
      const conditions = [];
      if (pipelineId) {
        conditions.push([`a.pipelineId = :pipelineId`, { pipelineId }]);
      }
      return conditions;
    }
  }
})
export class AdminAutomationTaskController extends BaseController {
  @Inject()
  automationTaskService: AutomationTaskService;
}